import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrderLogisticsVO, OrderLogisticsForm, OrderLogisticsQuery } from '@/api/system/orderLogistics/types';
import { data } from 'autoprefixer';

/**
 * 查询球星卡订单列表
 * @param query
 * @returns {*}
 */

export const listOrderLogistics = (query?: OrderLogisticsQuery): AxiosPromise<OrderLogisticsVO[]> => {
  return request({
    url: '/system/cardOrder/getCardOrderLogisticsList',
    method: 'get',
    params: query
  });
};

/**
 * 查询球星卡订单详细
 * @param id
 */
export const getOrderLogistics = (id: string | number): AxiosPromise<OrderLogisticsVO> => {
  return request({
    url: '/system/cardOrder/' + id,
    method: 'get'
  });
};

/**
 * 新增球星卡订单
 * @param data
 */
export const addOrderLogistics = (data: OrderLogisticsForm) => {
  return request({
    url: '/system/cardOrder',
    method: 'post',
    data: data
  });
};

/**
 * 修改球星卡订单
 * @param data
 */
export const updateOrderLogistics = (data: OrderLogisticsForm) => {
  return request({
    url: '/system/cardOrder',
    method: 'put',
    data: data
  });
};

/**
 * 删除球星卡订单
 * @param id
 */
export const delOrderLogistics = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/cardOrder/' + id,
    method: 'delete'
  });
};

/**
 * 商家查询快递信息
 * @param id
 */
export const queryLogisticsExpressage = (logisticsId: any) => {
  return request({
    url: '/system/cardOrder/queryLogisticsExpressage?logisticsId=' + logisticsId,
    method: 'get',
  });
};

/**
 * 查看中卡
 * @param id
 */
export const getGainCardCarmiInfo = (query: any) => {
  return request({
    url: '/system/cardOrder/getGainCardCarmiInfo',
    method: 'get',
    params: query
  });
};

/**
 * 点击去发货按钮
 * @param id
 */
export const sendCardOrdersLogisticsExpressage = (id: string | number) => {
  return request({
    url: '/system/cardOrder/sendCardOrdersLogisticsExpressage/' + id,
    method: 'get'
  });
};

/**
 * 加载物流公司
 * @param id
 */
export const queryExpressageInfoList = (more: string) => {
  return request({
    url: '/system/cardOrder/queryExpressageInfoList/' + more,
    method: 'get'
  });
};

/**
 * 发货
 * @param id
 */
export const sendLogisticsExpressage = (data:any) => {
  return request({
    url: '/system/cardOrder/sendLogisticsExpressage',
    method: 'post',
    data: data
  });
};

/**
 * 查看订单物流
 * @param id
 */
export const getLogisticsInfo = (id: string | number) => {
  return request({
    url: '/system/cardOrder/getLogisticsInfo/'+ id,
    method: 'get',
  });
};

/**
 * 修改物流信息
 * @param id
 */
export const updateLogistics = (data: any) => {
  return request({
    url: '/system/cardOrder/updateLogistics',
    method: 'post',
    data: data
  });
};
